const express = require('express');
const router = express.Router();
const pagecontroller = require('./controller/pageController');
const adminUserController = require('./controller/adminUserController');
const categoryController = require('./controller/adminCategoryController');
const postController = require('./controller/adminPostsController');
// 监听不同的请求
// 返回前台主页
router.get('/',(req,res)=>{
    pagecontroller.getIndex(req,res);
});

router.get('/index',(req,res)=>{
    pagecontroller.getIndex(req,res);
});

// 返回前台页面
router.get('/list',(req,res)=>{
    pagecontroller.getList(req,res);
});

router.get('/detail',(req,res)=>{
    pagecontroller.getDetail(req,res);
});


// 返回后台主页
router.get('/admin',(req,res)=>{
    pagecontroller.getAdminIndex(req,res);
});

router.get('/admin/index',(req,res)=>{
    pagecontroller.getAdminIndex(req,res);
});

// 返回后台分类管理
router.get('/admin/login',(req,res)=>{
    pagecontroller.getAdminLogin(req,res);
});

router.get('/admin/categories',(req,res)=>{
    pagecontroller.getAdminCategories(req,res);
});

router.get('/admin/comments',(req,res)=>{
    pagecontroller.getAdminComments(req,res);
});

router.get('/admin/post-add',(req,res)=>{
    pagecontroller.getAdminPostAdd(req,res);
});

router.get('/admin/posts',(req,res)=>{
    pagecontroller.getAdminPosts(req,res);
});

router.get('/admin/profile',(req,res)=>{
    pagecontroller.getAdminProfile(req,res);
});

router.get('/admin/settings',(req,res)=>{
    pagecontroller.getAdminSettings(req,res);
});

router.get('/admin/slides',(req,res)=>{
    pagecontroller.getAdminSlides(req,res);
});

router.get('/admin/users',(req,res)=>{
    pagecontroller.getAdminUsers(req,res);
});

router.get('/admin/password-reset',(req,res)=>{
    pagecontroller.getAdminPasswordReset(req,res);
});

router.get('/getUserHN',(req,res)=>{
    adminUserController.getUserHN(req,res);
});


router.post('/admin_do_login',(req,res)=>{
    adminUserController.adminLogin(req,res);
});

router.post('/addNewCategories',(req,res)=>{
    categoryController.addNewCategories(req,res);
});

router.get('/deleteCategoryById',(req,res)=>{
    categoryController.deleteCategoryById(req,res);
});

router.get('/getCategoryById',(req,res)=>{
    categoryController.getCategoryById(req,res);
});

router.post('/editCategoryById',(req,res)=>{
    categoryController.editCategoryById(req,res);
});
// 监听批量删除
router.get('/deleteMultple',(req,res)=>{
    categoryController.deleteMultple(req,res);
});
// 根据分页获取文章数据
router.post('/getPostsByPage',(req,res)=>{
    postController.getPostsByPage(req,res);
});



module.exports = router;